﻿using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;

using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;

using AimGameEngine.EditorObject;

using AimGameLibrary;

namespace AimGameEngine.NodeEditorObject
{
    public class NodeSpriteEffects : NodeBaseControl
    {
        public SpriteEffects myeffects;

        public NodeSpriteEffects(SpriteBatch inputspritebatch, Camera inputcamera, NodeData inputData
            , List<IDraw> MyListDraw, List<IUpdateMainTime> MyListUpdateTime, Dictionary<String, NodeObject> MyListObject, Dictionary<String, NodeObject> MyListType)
            : base(inputspritebatch, inputcamera, inputData, MyListDraw,MyListUpdateTime, MyListObject, MyListType)
	    {
            myeffects = SpriteEffects.None;
            InputMode = NodeInputMode.None;
            Connecter outputSpriteEffects = new Connecter(inputspritebatch, inputcamera, Syco.Output, NodeTypeValue.SpriteEffects, this);
            ListConnectpoint.Add(outputSpriteEffects);
        }

        public override void SetupInput(Connecter Thisconnect, Connecter connectOutput)
        {
            if (InputMode == NodeInputMode.SpriteEffects_1)
            {
                MyData.Data = connectOutput.MyNode.MyData.MyName;
            }
        }

        public override void ClearInput(Connecter ThisInputConnect, Connecter ThisConnectClear, string NameThisClear)
        {
            MyData.Data = "NULL";
        }


        public override void ShowProprety(ArrayList Temp, CallBack input)
        {
            base.ShowProprety(Temp, input);
            PropretySpriteEffects eff = new PropretySpriteEffects(this);
            //eff.Deactivate += new EventHandler(input.Deactivate);
            eff.okButton.Click += new EventHandler(input.Deactivate);
            eff.ShowDialog();
            
        }

        public override void SetupProprety()
        {
            base.SetupProprety();

            if (InputMode == NodeInputMode.SpriteEffects_1)
            {
                Connecter inputSpriteEffects = new Connecter(this.spritebatch, this.camera, Syco.Input, NodeTypeValue.SpriteEffects, this);
                ListConnectpoint.Add(inputSpriteEffects);
            }

            this.AfterSetupProprety();
        }

        protected override Dictionary<string, NodeObject> GetDictionaryNode(Dictionary<string, NodeObject> TempNode)
        {
            if (this.MyData.Data != null)
                if (this.MyDictionaryObject.ContainsKey(this.MyData.Data))
                    TempNode.Add(this.MyData.Data, this.MyDictionaryObject[this.MyData.Data]);

            return base.GetDictionaryNode(TempNode);
        }

        public override void SaveData(System.Collections.ArrayList Thislist, SaveMode inputsavemode)
        {
            base.SaveData(Thislist, inputsavemode);

            Thislist.Add(InputMode);
            Thislist.Add(myeffects);
        }

        public override void LoadData(Identification getdata, int IndexData)
        {
            base.LoadData(getdata, IndexData);

            if (getdata.Items.GetValue(IndexData + 1).GetType() == typeof(NodeInputMode))
                InputMode = (NodeInputMode)getdata.Items.GetValue(IndexData + 1);

            if (getdata.Items.GetValue(IndexData + 2).GetType() == typeof(SpriteEffects))
                myeffects = (SpriteEffects)getdata.Items.GetValue(IndexData + 2);

            SetupProprety();
        }
    }
}
